package ink.ykb.demo.permission.dao;

import java.util.List;

import org.beetl.sql.core.annotatoin.Sql;
import org.beetl.sql.core.mapper.BaseMapper;

import ink.ykb.demo.permission.entity.DealerDepartment;

/*
* 
* gen by beetlsql mapper 2019-09-23
*/
public interface DealerDepartmentDao extends BaseMapper<DealerDepartment> {

	/**
	 * 根据name获取经销商层级(加锁)
	 * 
	 * @param name
	 * @return
	 */
	@Sql("select * from dealer_department where name = ? for update")
	DealerDepartment getDealerDepartmentAndLock(String name);

	/**
	 * 根据name获取经销商层级
	 * 
	 * @param name
	 * @return
	 */
	@Sql("select * from dealer_department where name = ?")
	DealerDepartment getDealerDepartment(String name);

	/**
	 * 根据id获取经销商层级
	 * 
	 * @param id
	 * @return
	 */
	@Sql("select * from dealer_department where id = ?")
	DealerDepartment getDealerDepartmentById(Long id);

	/**
	 * 查询所有经销商层级
	 * @return
	 */
	@Sql("select * from dealer_department")
	List<DealerDepartment> getDealerDepartmentList();
	
	/**
	 * 根据父级id获取经销商层级
	 * 
	 * @param parentId
	 * @return
	 */
	@Sql("select * from dealer_department where parent_id = ?")
	List<DealerDepartment> getByParentId(Long parentId);
}
